/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Player;

import Items.Item;
import java.io.Serializable;
import java.util.ArrayList;

/**
 *
 * @author insane
 */
public class Player implements Serializable {

    protected String name; // имя
    protected int Type;     // класс
    protected int Str;       // сила
    protected int Int;       // интеллект
    protected int Dex;       // ловкость
    protected int Hlt;       // здоровье
    protected int Health;
    protected int Cha;       // харизма
    protected int age = 0;
    protected int level = 1;
    protected int exp = 0;
    private int expPoints = 0;
    private int step = 0;
    private int money = 100;
    private ArrayList<Item> InventoryItems = null;

    protected Player(){

    }

    private void init() {

    }

    public int getNextLevel(int level) {
        return level * 10 + level * level;
    }

    protected String getTypeName() {
        switch (this.Type) {
            case 1:
                return "Warrior";
            case 2:
                return "Rogue";
        }
        return null;
    }

    /**
     * @return the name
     */
    public String getName() {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * @return the Type
     */
    public int getType() {
        return Type;
    }

    /**
     * @param Type the Type to set
     */
    public void setType(int Type) {
        this.Type = Type;
    }

    /**
     * @return the Str
     */
    public int getStr() {
        return Str;
    }

    /**
     * @param Str the Str to set
     */
    public void setStr(int Str) {
        this.Str = Str;
    }

    /**
     * @return the Int
     */
    public int getInt() {
        return Int;
    }

    /**
     * @param Int the Int to set
     */
    public void setInt(int Int) {
        this.Int = Int;
    }

    /**
     * @return the Dex
     */
    public int getDex() {
        return Dex;
    }

    /**
     * @param Dex the Dex to set
     */
    public void setDex(int Dex) {
        this.Dex = Dex;
    }

    /**
     * @return the Hlt
     */
    public int getHlt() {
        return Hlt;
    }

    /**
     * @param Hlt the Hlt to set
     */
    public void setHlt(int Hlt) {
        this.Hlt = Hlt;
    }

    /**
     * @return the Cha
     */
    public int getCha() {
        return Cha;
    }

    /**
     * @param Cha the Cha to set
     */
    public void setCha(int Cha) {
        this.Cha = Cha;
    }

    /**
     * @return the age
     */
    public int getAge() {
        return age;
    }

    /**
     * @param age the age to set
     */
    public void setAge(int age) {
        this.age = age;
    }

    /**
     * @return the level
     */
    public int getLevel() {
        return level;
    }

    /**
     * @param level the level to set
     */
    public void setLevel(int level) {
        this.level = level;
    }

    /**
     * @return the exp
     */
    public int getExp() {
        return exp;
    }

    /**
     * @param exp the exp to set
     */
    public void setExp(int exp) {
        this.exp += exp;
        this.checkLevel();
    }

    private void checkLevel(){
         if( this.getExp() > this.getNextLevel( this.getLevel() )){
            this.setLevel(this.getLevel() + 1);
            this.setExpPoints(this.getExpPoints() + 5);
            this.checkLevel();
        }
    }

    /**
     * @return the step
     */
    public int getStep() {
        return step;
    }

    /**
     * @param step the step to set
     */
    public void setStep(int step) {
        this.step = step;
    }

    /**
     * @return the InventoryItems
     */
    public ArrayList<Item> getInventoryItems() {
        return InventoryItems;
    }

    /**
     * @param InventoryItems the InventoryItems to set
     */
    public void setInventoryItems(ArrayList<Item> InventoryItems) {
        this.InventoryItems = InventoryItems;
    }

    /**
     * @return the money
     */
    public int getMoney() {
        return money;
    }

    /**
     * @param money the money to set
     */
    public void setMoney(int money) {
        this.money = money;
    }

    public int getMaxHealth(){
        return this.Hlt * 30;
    }

    /**
     * @return the Health
     */
    public int getHealth() {
        return Health;
    }

    /**
     * @param Health the Health to set
     */
    public void setHealth(int Health) {
        this.Health = Health;
    }

    public void addLive(int health){
        this.Health+=health;
        if(this.Health > this.getMaxHealth()) this.Health = this.getMaxHealth();
        return;
    }

    /**
     * @return the expPoints
     */
    public int getExpPoints() {
        return expPoints;
    }

    /**
     * @param expPoints the expPoints to set
     */
    public void setExpPoints(int expPoints) {
        this.expPoints = expPoints;
    }

    public void addStr(){
        if(this.expPoints > 0){
            this.expPoints -= 1;
            this.setStr(this.getStr() + 1);
        }
    }

    public void addDex(){
        if(this.expPoints > 0){
            this.expPoints -= 1;
            this.setDex(this.getDex() + 1);
        }
    }

    public void addHlt(){
        if(this.expPoints > 0){
            this.expPoints -= 1;
            this.setHlt(this.getHlt() + 1);
        }
    }

    public void addInt(){
        if(this.expPoints > 0){
            this.expPoints -= 1;
            this.setInt(this.getInt() + 1);
        }
    }

}
